package com.steven.http;

import io.netty.channel.Channel;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.socket.SocketChannel;
import io.netty.handler.codec.http.HttpServerCodec;

public class ServerInitializer extends ChannelInitializer<SocketChannel> {

    @Override
    protected void initChannel(SocketChannel socketChannel) throws Exception {
        //管道加入处理
        //得到管道
        ChannelPipeline pipeline = socketChannel.pipeline();
        //加入编码解码器
        pipeline.addLast("Codec",new HttpServerCodec());
        //加入自己的处理器
        pipeline.addLast("httpHandler",new HttpHandler());
    }
}
